#ifndef IMAGE_H
#define IMAGE_H
#include <map>
#include <string>
#include "Object.h"
#include "util.h"
using namespace std;
#include <stdio.h>


#define INT_OBJECT_DATA_OFFSET 4
#define BOOLEAN_OBJECT_DATA_OFFSET 4
#define STRING_OBJECT_LENGTH_OFFSET 4
#define STRING_OBJECT_DATA_OFFSET 8
#define ARRAY_OBJECT_LENGTH_OFFSET 4
#define ARRAY_OBJECT_DATA_OFFSET 8

class Class;
class Image:public Object{
   public:
      Image();
      void* alloc(size_t amount);
      void* realloc(void* mem,size_t newAmount);
      void free(void* mem);
      Class* getClass(string name);
      Object* getObject(string name);
      void addObject(string name,Object* object);
      void addClass(string name,Class* cls);
      void exception(string message);
      //convenient named classes
      Class* clsInteger;
      Class* clsBoolean;
      Class* clsString;
      Class* clsCodeMethod;
      Class* clsMethod;
      Class* clsIClosure;
      Class* clsClass;
      Class* clsXClass;
      Class* clsObject;
      Class* clsArray;
      Class* clsNull;
      Class* clsRange;
      ~Image();
   private:
      void* stackHandlePlace;
      map<string,Class*> classes;
      map<string,Object*> worldDict;
};
#endif
Object* primitive_image_add_object(Image* image,Object* self,int argc,Object** argv);